package com.linkstec.keyrobot;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;

/**
 * @author
 * 
 */
public class KeyRobot {
	static int i = 0;
    public static void pressKey() {
        Robot robot = null;
        try {
            robot = new Robot();
            robot.setAutoDelay(60000);//每1分钟按下一次
//            robot.setAutoDelay(10000);
//            robot.keyPress(KeyEvent.VK_CAPS_LOCK);
            robot.keyPress(KeyEvent.VK_CANCEL);
//            robot.keyPress(KeyEvent.VK_ENTER);
//            robot.keyPress(KeyEvent.VK_BACK_SPACE);
            i++;
            System.out.println("按"+ i +"次");
            System.out.println("第"+ i/60 +"小时" + i%60 + "分");
//            robot.keyRelease(KeyEvent.VK_CAPS_LOCK);
        } catch (AWTException e) {
            e.printStackTrace();
        }
    }
}